package org.spiderdesign.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.spiderdesign.core.model.Employee;
import org.spiderdesign.core.service.EmployeeService;
import org.spiderdesign.model.JsonBean;
import org.spiderdesign.model.login.dto.LoginDTO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class LoginController {
    @Resource
    private EmployeeService employeeService;

    @RequestMapping("/login")
    public JsonBean<Void> login(@RequestBody LoginDTO loginDTO, HttpServletRequest request, HttpServletResponse response) {
        return employeeService.login(request,response,loginDTO.getLoginName(),loginDTO.getLoginPwd());
    }

    @RequestMapping("/logout")
    public JsonBean<Void> logout(HttpServletRequest request) {
        return employeeService.logout(request);
    }

}
